<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div class="pagination">
	<ul>
        <li <c:if test="${!page.hasPrevious }">class="disabled"</c:if>> 
			<a <c:if test="${page.hasPrevious }">href="?${params }curPage=${page.current - 1 }"</c:if>>&lt;&lt;</a>
		</li>
		<c:set var="startPageIndex" value="1"/>
		<c:set var="endPageIndex" value="1"/>
		<c:choose>
		  <c:when test="${page.current < 6 }">
		      <c:set var="startPageIndex" value="1"/>
		  </c:when>
		  <c:when test="${page.current > 6 && (page.totalPages-page.current) > 4}">
		      <c:set var="startPageIndex" value="${page.current-5 }"/>
		  </c:when>
		  <c:otherwise>
		      <c:set var="startPageIndex" value="${page.totalPages-9 }"/>
		  </c:otherwise>
		</c:choose>
		
		<c:set var="endPageIndex" value="${startPageIndex+9 }"/>
		<c:if test="${endPageIndex > page.totalPages }">
		   <c:set var="endPageIndex" value="${page.totalPages }"/>
		</c:if>
		
		<c:forEach var="i" begin="${startPageIndex }" end="${endPageIndex }">
        <li <c:if test="${page.current==i }">class="active"</c:if>>
        	<a href="?${params }curPage=${i }">${i }</a>
        </li>
        </c:forEach>
        
        <li <c:if test="${!page.hasNext}">class="disabled"</c:if>> 
			<a <c:if test="${page.hasNext}">href="?${params }curPage=${page.current + 1 }"</c:if>>&gt;&gt;</a>
		</li>
	</ul>
</div>